import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { usePermission } from '/@/hooks/web/usePermission';
const { hasPermission } = usePermission();
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import { h } from 'vue';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '单位编号',
    align: 'center',
    dataIndex: 'id',
    width: 50,
  },
  {
    title: '单位名称',
    align: 'center',
    dataIndex: 'mc',
    width: 180,
  },
  {
    title: '负责人姓名',
    align: 'center',
    dataIndex: 'fzrxm',
    width: 100,
  },
  {
    title: '负责人电话',
    align: 'center',
    dataIndex: 'fzrlxdh',
    width: 120,
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'bz',
    width: 180,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '单位名称',
    field: 'mc',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: '负责人电话',
    field: 'fzrlxdh',
    component: 'Input',
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '单位名称',
    field: 'mc',
    component: 'Input',
  },
  {
    label: '负责人姓名',
    field: 'fzrxm',
    component: 'Input',
  },
  {
    label: '负责人电话',
    field: 'fzrlxdh',
    component: 'Input',
  },

  {
    label: '地址',
    field: 'dz',
    component: 'Input',
  },

  {
    label: '备注',
    field: 'bz',
    component: 'Input',
  },

  {
    label: 'Appkey',
    field: 'appkey',
    component: 'Input',
    ifShow: ({ values }) => {
      return !!values.id;
    },
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
    show: ({ values }) => {
      return hasPermission('wyf:wyf_pms:keys');
    }
  },
  {
    label: 'Appsecret',
    field: 'appsecret',
    component: 'Input',
    ifShow: ({ values }) => {
      return !!values.id;
    },
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
    show: ({ values }) => {
      return hasPermission('wyf:wyf_pms:keys');
    }
  },

  {
    label: 'pubkey',
    field: 'pubkey',
    component: 'InputTextArea',
    ifShow: ({ values }) => {
      return !!values.id;
    },
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
    show: ({ values }) => {
      return hasPermission('wyf:wyf_pms:keys');
    }
  },

  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  mc: { title: '单位名称', order: 0, view: 'text', type: 'string' },
  fzrlxdh: { title: '负责人联系电话', order: 1, view: 'text', type: 'string' },
  appkey: { title: 'appkey', order: 2, view: 'text', type: 'string' },
  appsecret: { title: 'appsecret', order: 3, view: 'text', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
